⬡ Hub
Skip to content

AWS Migration Strategies and Guide

This document provides a comprehensive guide to various migration scenarios involving AWS, including On-Premises to Cloud, Cloud to On-Premises, Cloud to Cloud, and Database Migrations.

1. Migration Overview

Migration is the process of moving applications, data, and infrastructure from one environment to another. The "6 Rs" of migration strategies are commonly cited:

  1. Rehost (Lift and Shift): Moving applications to the cloud without changes.
  2. Replatform (Lift, Tinker, and Shift): Making a few cloud optimizations to achieve some tangible benefit, but not changing the core architecture of the application.
  3. Refactor (Re-architect): Re-imagining how the application is architected and developed, typically using cloud-native features.
  4. Repurchase: Moving to a different product, usually a SaaS platform.
  5. Retain: Keeping applications as-is in the source environment.
  6. Retire: Decommissioning applications that are no longer needed.

2. On-Premises to Cloud (AWS)

Scenarios

  • Legacy application migration.
  • Data center exit.
  • Scalability and flexibility needs.

Tools

  • AWS Application Migration Service (MGN): The primary tool for lift-and-shift migrations. It replicates source servers into your AWS account.
  • AWS Server Migration Service (SMS): (Legacy) Agentless migration.
  • AWS Database Migration Service (DMS): For database migrations.
  • AWS Snow Family: For large offline data transfers (Snowball, Snowmobile).

Process (Lift and Shift with MGN)

  1. Assessment: Identify servers and dependencies.
  2. Initialize MGN: Set up the replication service in AWS.
  3. Install Agent: Install the AWS Replication Agent on source servers (Linux/Windows).
  4. Replication: Initial sync of data to AWS (continuous replication).
  5. Test Cutover: Launch instances in AWS in a test mode to verify functionality.
  6. Cutover: Final sycn, stop source, launch production instances in AWS.

3. Cloud to On-Premises (Repatriation)

Scenarios

  • Regulatory/Compliance requirements requiring local data residency.
  • Cost optimization for stable, predictable workloads.
  • Latency sensitivity requiring edge compute.

Tools

  • VM Import/Export: Export EC2 instances as virtual machine images (OVA/VMDK) to run on VMWare or Hyper-V.
  • Database Native Backup/Restore: SQL dumps, RMAN backups (Oracle).
  • AWS Storage Gateway: Bridge on-prem apps with cloud storage.

Process

  1. Prepare Image: Stop the EC2 instance or create an AMI.
  2. Export: Use AWS CLI/Console to export the instance to an S3 bucket as a VM image.
  3. Download: Download the image file from S3 to local infrastructure.
  4. Import: Import into the virtualization platform (VMware, Hyper-V).
  5. Configure: Adjust networking, drivers, and license keys.

4. Cloud to Cloud (e.g., Azure/GCP to AWS)

Scenarios

  • Multi-cloud strategy.
  • Vendor lock-in mitigation.
  • Feature processing.

Approaches

  • Treat Source as On-Prem: Use AWS MGN agents on Azure/GCP VMs to replicate them to AWS like physical servers.
  • Infrastructure as Code (IaC): If the app is containerized or strictly defined in Terraform/Ansible, redeploy the stack on AWS and just migrate the data.

5. Database Migrations

Scenarios

  • Homogeneous: Same engine (e.g., Oracle to Oracle on RDS, SQL Server to SQL Server on EC2/RDS).
  • Heterogeneous: Different engine (e.g., Oracle to PostgreSQL, SQL Server to Aurora MySQL).

Tools

  • AWS Database Migration Service (DMS): Moves data. Supports ongoing replication (CDC).
  • AWS Schema Conversion Tool (SCT): Converts database schema (tables, views, stored procedures) from source engine format to target engine format.

Example: SQL Server to PostgreSQL

  1. Schema Conversion: Use SCT to analyze SQL Server schema and generate PostgreSQL compatible SQL. Apply to target.
  2. Data Migration: Create a DMS Replication Instance.
  3. Endpoints: Define Source (SQL Server) and Target (PostgreSQL) endpoints in DMS.
  4. Task: Create a migration task (Full Load + CDC).
  5. Run: Start the task and monitor for errors.

Example: SQL Server to Aurora

Similar to above. Aurora supports both MySQL and PostgreSQL compatibility modes. The process involves SCT for schema and DMS for data.


Automated Scripts

The Scripts directory contains automation scripts for: 1. on_prem_to_cloud_migration.sh: Uses AWS MGN API to automate agent installation and server lifecycle. 2. cloud_to_cloud_migration.sh: Conceptual wrapper for cross-cloud migration often leveraging MGN or snapshot copies. 3. db_sql_to_postgres_dms.sh: Automates AWS DMS resource creation for SQL -> Postgres. 4. db_sql_to_aurora_dms.sh: Automates AWS DMS resource creation for SQL -> Aurora. 5. cloud_to_on_prem_export.sh: Automates VM Export of an EC2 instance to S3.